package com.annotation;

import java.lang.reflect.Field;

public class CheckPerson {

    public void Check(Person person) throws IllegalArgumentException, ReflectiveOperationException {

        //反射获取相应的变量
        for(Field field: person.getClass().getFields()){

            Report re = field.getAnnotation(Report.class);//反射获取相应的注解

            if(re !=null){

                Object value = field.get(person);

                if( value instanceof  String){

                    String s = (String)value;

                    if(s.length()<re.min()||s.length()>re.max()){
                        throw new IllegalArgumentException("Invalid field: " + field.getName());
                    }
                }
            }


        }
    }
    public static void main(String[] args){



    }
}
